function LineChart(chartDiv,title,yAxisName,type,startTime,endTime,dataMap){
	this.chartDiv = chartDiv;
	this.title = title;
	this.yAxisName = yAxisName;
	this.type=type;
	this.startTime=startTime;
	this.endTime = endTime;
	this.dataMap = dataMap;
	this.chartString = generateDataString();
	function generateDataString(){
		var DAY = 24*60*60*1000;
		var dataStr ="<chart caption='"+ title+"' baseFontSize='12' palette='3' YAxisName='"+ yAxisName+"' numdivlines='8' lineThickness='2' showValues='0' anchorRadius='4' anchorBgAlpha='50' numVDivLines='11' showAlternateVGridColor='1' alternateVGridAlpha='3' formatNumber='0' formatNumberScale='0' animation='1' numVisiblePlot='12'>";
		if(type=="day"){
			var FORMAT ="yyyy-MM-dd";
			var startDate = Date.parse(startTime,FORMAT);
			var endDate =  Date.parse(endTime,FORMAT);
			var start = startDate.valueOf();
			var end = endDate.valueOf();
			dataStr+="<categories >";
			for(var time = start;time<=end;time+=DAY){
				var day = new Date();
				day.setTime(time);
				var key = day.format("MM-dd");
				dataStr+="<category label='"+key+"' />";
			}
			dataStr+="</categories>";
			dataStr+="<dataset>";
			for(var time = start;time<=end;time+=DAY){
				var day = new Date();
				day.setTime(time);
				var key = day.format(FORMAT);
				var value = dataMap[key];
				if (value === undefined){
					value =0;
				}
	    		dataStr+='<set value="'+value+'"/>';
			}
			dataStr+="</dataset>";
			dataStr+="</chart>";
		}else if(type=="week"){
			var FORMAT ="yyyy-MM-dd";
			var startDate = Date.parse(startTime,FORMAT);
			var endDate =  Date.parse(endTime,FORMAT);
			var start = startDate.valueOf();
			var end = endDate.valueOf();
			dataStr+="<categories >";
			for(var time = start;time<=end;time+=7*DAY){
				var day = new Date();
				day.setTime(time);
				var key = day.format("MM-dd");
				dataStr+="<category label='"+key+"' />";
			}
			dataStr+="</categories>";
			dataStr+="<dataset>";
			for(var time = start;time<=end;time+=7*DAY){
				var day = new Date();
				day.setTime(time);
				var key = day.format(FORMAT);
				var value = dataMap[key];
				if (value === undefined){
					value =0;
				}
	    		dataStr+='<set value="'+value+'"/>';
			}
			dataStr+="</dataset>";
			dataStr+="</chart>";
		}else{
			dataStr+="<categories >";
			for(var time = start;time<=end;time++){
				dataStr+="<category label='"+time+"' />";
			}
			dataStr+="</categories>";
			dataStr+="<dataset>";
			for(var time = start;time<=end;time+=DAY){
				var value = dataMap[time];
				if (value === undefined){
					value =0;
				}
	    		dataStr+='<set value="'+value+'"/>';
			}
			dataStr+="</dataset>";
			dataStr+="</chart>";
		}
        return dataStr;
    }
};
LineChart.prototype.draw = function(){
	var chart = new FusionCharts("../static/FusionCharts/ScrollLine2D.swf", "LineChartId", "726", "325", "0", "0");
    chart.setXMLData(this.chartString);
    chart.render(this.chartDiv);
};

